class Solution:
    def reconstructQueue(self, people):
        """
        :type people: List[List[int]]
        :rtype: List[List[int]]
        """
        n = len(people)
        if n == 0:
            return []
        people = sorted(people, key=lambda x: (-x[0], x[1]))
        res = []
        for i in range(len(people)):
            res.insert(people[i][1], people[i])
        return res
